The invention relates generally to computer database systems and more particularly, but not by way of limitation, to methods and devices for reorganizing database files.
Databases may be characterized as comprising two types of “objects”—data objects and index objects. Both data and index objects are typically embodied as files stored on one or more direct access storage devices (DASDs). The process of reorganizing a database, then, generally involves reading a database object (“unloading”), passing the data to a sort utility that reorders (sorts) the data in accordance with a specified sort key and writing the data back to the object in a new sequence determined by the sort key (“reloading”). The needs for sorting are many and varied and are well-known to those of ordinary skill in the art of database system use and design. For example, periodic sorting of database objects can improve a user's response time during database search and retrieval operations.
A typical prior art technique for sorting a database object is shown in FIG. 1. Initially, prior art reorganization process 100 interrogates the targeted database to determine various structural and logical details needed to inform the sort operation (block 105). Illustrative details include, for example, the locations and names of the files in which the database data is physically stored and the identification and location of the sort key(s) within the targeted data. Next, reorganization process 100 obtains data records from the target database (block 110) and passes them to a sort routine (block 115). If additional records remain to be read from the target database (the “NO” prong of block 120), the acts of blocks 110 and 115 are repeated. If no additional records remain to be read (the “YES” prong of block 120), the sorted records are written back to the target database in their new (sorted) sequence (block 125). Following completion of write-back operations in accordance with block 125, the reorganization routine terminates (block 130).
One significant drawback to prior art database reorganization techniques is that for large databases consisting of hundreds of gigabytes to tens of terabytes, the time required to perform the read and write-back operations (e.g., blocks 110 and 125 in FIG. 1) can be significant. Thus, it would be beneficial to provide a technique to reorganize database objects that is more time efficient than current techniques.